home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / ReadPixX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  4.3 KB  |  122 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. /* Define calls if using function pointers or not */
  40. #ifdef FUNCTION_PTRS
  41.   #ifdef MULTIIMAGE
  42.     #define READPIX_CALL   (*readPixels)(x, y, width, height, format, type, *imagePtr++);
  43.   #else
  44.     #define READPIX_CALL   (*readPixels)(x, y, width, height, format, type, image);
  45.   #endif
  46.   #define PIXELSTORE_CALL  (*pixelStore)
  47. #else
  48.   #ifdef MULTIIMAGE
  49.     #define READPIX_CALL   glReadPixels(x, y, width, height, format, type, *imagePtr++);
  50.   #else
  51.     #define READPIX_CALL   glReadPixels(x, y, width, height, format, type, image);
  52.   #endif
  53.   #define PIXELSTORE_CALL  glPixelStorei
  54. #endif
  55.  
  56. void FUNCTION (TestPtr thisTest)
  57. {
  58.     ReadPixelsPtr this = (ReadPixelsPtr)thisTest;
  59.     int iterations = this->iterations;
  60.     int numDrawn = this->numDrawn;
  61.     int width = this->readPixelsWidth;
  62.     int height = this->readPixelsHeight;
  63.     int x, y;
  64.   #ifdef SUBIMAGE
  65.     GLint imageWidth = this->image_ReadPixels.imageWidth;
  66.   #endif
  67.     int format = this->image_ReadPixels.imageFormat;
  68.     int type = this->image_ReadPixels.imageType;
  69.     int i,j;
  70.   #ifdef MULTIIMAGE
  71.     int numObjects = this->numObjects;
  72.     int k;
  73.     void **imageData = this->imageData;
  74.     void **imagePtr = imageData;
  75.   #else
  76.     void *image = *(this->imageData);
  77.   #endif
  78.   #ifdef SUBIMAGE
  79.     GLint *subImageData = this->subImageData;
  80.     GLint *subPtr = subImageData;
  81.   #endif
  82.     GLint *srcData = this->srcData;
  83.     GLint *posPtr = srcData;
  84.   #ifdef FUNCTION_PTRS
  85.    #ifdef WIN32
  86.     void (APIENTRY *readPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*) = glReadPixels;
  87.     void (APIENTRY *pixelStore)(GLenum, GLint) = glPixelStorei;
  88.    #else
  89.     void (*readPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*) = glReadPixels;
  90.     void (*pixelStore)(GLenum, GLint) = glPixelStorei;
  91.    #endif
  92.   #endif
  93.  
  94.   #ifdef SUBIMAGE
  95.     PIXELSTORE_CALL(GL_UNPACK_ROW_LENGTH, imageWidth);
  96.   #endif
  97.     for (i = iterations; i > 0; i--) {
  98.     for (j = numDrawn; j > 0; j--) {
  99.       #ifdef SUBIMAGE
  100.         PIXELSTORE_CALL(GL_UNPACK_SKIP_PIXELS, *subPtr++);
  101.         PIXELSTORE_CALL(GL_UNPACK_SKIP_ROWS, *subPtr++);
  102.       #endif        
  103.         x = *posPtr++;
  104.         y = *posPtr++;
  105.           #ifdef MULTIIMAGE
  106.         for (k = numObjects; k > 0; k--)
  107.           #endif
  108.         READPIX_CALL
  109.           #ifdef MULTIIMAGE
  110.         imagePtr = imageData;
  111.           #endif
  112.     }
  113.     posPtr = srcData;
  114.       #ifdef SUBIMAGE
  115.     subPtr = subImageData;
  116.       #endif
  117.     }
  118. }
  119.  
  120. #undef READPIX_CALL
  121. #undef PIXELSTORE_CALL
  122.